﻿using System.Windows;

namespace Silverstone
{
    public class CommandBinder
    {
        public static readonly DependencyProperty CommandProperty = DependencyProperty.RegisterAttached("Command",
            typeof(ICommand), typeof(CommandBinder), new PropertyMetadata(CommandManager.HandleCommandPropertyChanged));

        public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.RegisterAttached("CommandParameter",
            typeof(object), typeof(CommandBinder), new PropertyMetadata(CommandManager.HandleCommandParameterPropertyChanged));

        public static void SetCommand(DependencyObject d, ICommand command)
        {
            d.SetValue(CommandProperty, command);
        }

        public static ICommand GetCommand(DependencyObject d)
        {
            return (ICommand) d.GetValue(CommandProperty);
        }

        public static void SetCommandParameter(DependencyObject d, object o)
        {
            d.SetValue(CommandParameterProperty, o);
        }

        public static object GetCommandParameter(DependencyObject d)
        {
            return d.GetValue(CommandParameterProperty);
        }
    }
}
